const zeroWidthSpace = '\u200B';

extension StringEx on String {

  String trimUnicodeEmptyChar() {
    return replaceAll(RegExp(r'\u0000'), '');
  }

  String get breakAll {
    // Makes the string in [Text] widget behave like with CSS style `word-break: break-all;`
    // (src: https://github.com/flutter/flutter/issues/61081#issuecomment-1103330522)
    return runes
        .map<String>(
            (element) => '${String.fromCharCode(element)}$zeroWidthSpace')
        .join();
  }

  String get unBreakAll {
    return replaceAll(zeroWidthSpace, String.fromCharCode(0xFFFC));
  }
}
